let a =10
a = 23

let b:number =100
let c:string = "hello"
let d:boolean=true

//数组
let scores1:number[] = [1,3,54,2,4]
let scores2:string[] = ["asd","wqe","gcxs"]

//元组
let ccc:[number,string]
ccc=[2312,"afasaf"]

//枚举(enum)
enum Role{
    Admin,
    User,
    Guest
}
let role:Role=Role.Admin
console.log(role)

//接口(Interface)
interface User{
    name:string,
    age:number
}
let user1:User ={
    name:"zs",
    age:123
}
//函数
function add(num1:number,num2:number):number{
    return num1+num2
}

var result:number =add(2,5);
console.log(result)

add(1,2)

let person:{name:string,age:number}={
    name:"zs",
    age:30
}

function getPerson():{name:string,age:number}{
    return {
        name:"zs",
        age:123,
    }
}

//联合类型
let xxx:string | number
xxx="abc"
xxx=23

let fff:string | {name:string,age:number}

function print(id:string|number):string|number{
    return id
}
//交叉类型
let yyy:string & number

let ppp:{name:string} & {age:number}
ppp = {
    name:"zhangsan",
    age:30
}


//类型别名
type ID = string | number
let ggg:ID = "abcd"

type Person={
    name:string,
    age:number
}
let user111:Person={
    name:"zs",
    age:23
}

type Pers = User

type arr= string[]
let arr1:arr =["a","c"]

type a1 = [string,number]
let all:a1=["a",12]

//---------------------
//可选类型
interface Dog{
    name:string,
    age:number,
    mao?:string
}
let dog1:Dog={
    name:"gou",
    age:3,
    mao:"#aaaa"
}
let dog2:Dog={
    name:"zvafs",
    age:3,
}

//-----------------









